package com.tuanzi.loan.web.lazy.receipt.user;

import org.springframework.data.domain.Page;

import com.google.common.collect.Lists;
import com.tuanzi.loan.business.entity.receipt.user.ReceiptSystemUserStatus;
import com.tuanzi.loan.business.service.receipt.user.ReceiptSystemUserService;
import com.tuanzi.loan.core.lazy.BaseLazyDataModel;
import com.tuanzi.loan.core.util.SpringContextHolder;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.receipt.user.ReceiptSystemUserSearchRequest;
import com.tuanzi.loan.vo.response.receipt.user.ReceiptSystemUserSearchResponse;

/**
 * @author Ray 2017/09/21
 */
public class ReceiptSystemUserApproveLazyDataModel extends BaseLazyDataModel<ReceiptSystemUserSearchRequest, ReceiptSystemUserSearchResponse> {

	private static final long serialVersionUID = -4670419347550704982L;

	private ReceiptSystemUserService receiptSystemUserService = SpringContextHolder.getBean(ReceiptSystemUserService.class);

	public ReceiptSystemUserApproveLazyDataModel(ReceiptSystemUserSearchRequest request) {
		super(request);
	}

	@Override
	protected Page<ReceiptSystemUserSearchResponse> doLoad(PageSearcher<ReceiptSystemUserSearchRequest> pageSearcher) {
		pageSearcher.getSearchCondition().setLimitStatus(Lists.newArrayList(ReceiptSystemUserStatus.APPROVING.ordinal()));
		return receiptSystemUserService.list(pageSearcher);
	}

}
